<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
    function index(){
        $this->display();
    }
    function login(){
        $log = M("Admin");
        $username = $_POST["username"];
        $password = md5($_POST["password"]);
        $re  = $log->where("username='%s' and password='%s'",array($username,$password))->find();
        if($re){
            session_start();
            $_SESSION["id"]=$re["id"];
            $_SESSION["username"]=$username;
            $_SESSION["status"]=$re["status"];
            $this->success("登陆成功！",U("Index/index"));
        }else{
            $this->error("账号密码错误",U("Login/index"));
            exit;
        }
    }


}